<cfcomponent output="false">

	<!--- --->

	<cffunction name="renderBody" access="public" output="false" returntype="string">
		
		<cfset var local = {} />
		
		<cfsavecontent variable="local.result">
			<cfoutput>
				<div id="fund_body">
					<div id="fund_leftArea">
						#renderLeftBrowse()#
					</div><div id="funds">
						<div id="ScrollFunds">
							#renderFunds()#
						</div>
					</div>
				</div>
			</cfoutput>
		</cfsavecontent>
		
		<cfreturn local.result />
		
	</cffunction>
	
	<!--- --->
	
	<cffunction name="renderLeftBrowse" access="public" output="false" returntype="string">
		
		<cfset var local = {} />
		
		<cfsavecontent variable="local.result">
			<cfoutput>
				<div id="leftBrowseDiv" class="leftArea">
					<input name="fundid" validate="" value="" placeholder="Fund ID" size="18">
					<input name="city" validate="" value="" placeholder="Fund City" size="18">
					#application.q.select("stateID",application.s.resourceService.getStates(),"",true,"- Fund State -")#
					<input name="email" validate="email" value="" placeholder="Owner Email" size="18">
					<input name="owner_name" validate="" value="" placeholder="Owner Name" size="18">
					<input name="title" validate="" value="" placeholder="Fund Name" size="18">
					<input name="description" validate="" value="" placeholder="Fund Description" size="18">
					<input name="created" validate="date" value="" placeholder="Created Date" size="18">
					#application.q.checkbox("open","Open Funds")#
					#application.q.checkbox("closed","Closed Funds")#
					<button class="" onclick="javascript:void(0);">Clear</button>
					<button class="" onclick="javascript:Topbar.filterFunds();">Filter</button>
				</div>
				<div id="leftCreateDiv" class="leftArea hidden">
					<input name="title" validate="required" value="" placeholder="Title" size="18">
					<input name="who" validate="required" value="" placeholder="Who?" size="18">
					<input name="description" type="textarea" validate="required" value="" placeholder="Description" size="18">
					$<input name="amount" validate="money,positive" value="" placeholder="Fund Goal (optional)" size="17">
					<input name="end_date" validate="date" value="" placeholder="End Date (optional)" size="18">
					#application.q.checkbox("private","Private")#
					<button class="" onclick="javascript:Topbar.createFund();">Create Fund</button>
				</div>
			</cfoutput>
		</cfsavecontent>
		
		<cfreturn local.result />
		
	</cffunction>
	
	<!--- --->
	
	<cffunction name="renderFund" access="public" output="false" returntype="string">
		<cfargument name="id" required="true" />
		<cfargument name="title" required="true" />
		<cfargument name="who" required="true" />
		<cfargument name="amount" required="true" />
		<cfargument name="description" required="true" />
		<cfargument name="city" required="true" />
		<cfargument name="state" required="true" />
		
		<cfset var local = {} />
		
		<cfsavecontent variable="local.result">
			<cfoutput>
				<div class="fund_container">
					<div class="fund_contents">
						<table width="100%" id="#arguments.id#" class="fund_table" cellspacing="0" cellpadding="0">
							<tr class="fundTopRow">
								<td>
									#renderFundTopRow(argumentCollection=arguments)#
								</td>
							</tr>
							<tr class="fundMiddleRow">
								<td>
									#renderFundMiddleRow(description=arguments.description)#
								</td>
							</tr>
							<tr class="fundBottomRow">
								<td>
									#renderFundBottomRow(argumentCollection=arguments)#
								</td>
							</tr>
						</table>
					</div>
					<div class="fund_progress" style="width:#randRange(1,100)#%;">
						&nbsp;
					</div>
				</div>
			</cfoutput>
		</cfsavecontent>
		
		<cfreturn local.result />
		
	</cffunction>
	
	<!--- --->
	
	<cffunction name="renderFundTopRow" access="public" output="false" returntype="string">
		<cfargument name="title" required="true" />
		<cfargument name="who" required="true" />
		<cfargument name="amount" required="true" />
		<cfargument name="city" required="true" />
		<cfargument name="state" required="true" />
		<cfargument name="created" required="true" />
		
		<cfset var local = {} />
				
		<cfsavecontent variable="local.result">
			<cfoutput>
				<span class="fund_title title">#application.q.img(path="star_orange.png",style="height:20px;margin-bottom:-4px;")# <b>#arguments.title#</b></span>
				<div style="float:right;text-align:right;">
					<cfif isNumeric(arguments.amount)>
						<span class="title">Goal: $#decimalFormat(arguments.amount)#</span>
					</cfif>
					<div class="subtitle">#dateFormat(arguments.created,'mm/dd/yyyy')#</div>
				</div>
				<div class="fund_subtitle subtitle">
					&nbsp;#arguments.who# #arguments.city#,#arguments.state#
				</div>
			</cfoutput>
		</cfsavecontent>
		
		<cfreturn local.result />
		
	</cffunction>
	
	<!--- --->
	
	<cffunction name="renderFundBottomRow" access="public" output="false" returntype="string">
		<cfargument name="donor_count" required="false" default="3" />
		<cfargument name="funding_rate" required="false" default="154" />
		<cfargument name="weeks_togo" required="false" default="12" />
		<cfargument name="funded_percentage" required="false" default="34">
		
		<cfset var local = {} />
				
		<cfsavecontent variable="local.result">
			<cfoutput>
				<table width="100%" cellspacing="0" cellpadding="0">
					<tr>
						<td class="bottom_row_td" valign="bottom">
							#application.q.img(path='munich/user.png',style="height:18px;margin:-9px -45px 12px 0px;")#
							<span class="detail donor_count">#arguments.donor_count# funders</span>
						</td>
						<td class="bottom_row_td" valign="bottom">
							#application.q.img(path='munich/shipping.png',style="height:18px;margin:-9px -60px 11px 0px;")#
							<span class="detail">$#arguments.funding_rate# per week</span>
						</td>
						<td class="bottom_row_td" valign="bottom">
							#application.q.img(path='munich/full-time.png',style="height:18px;margin:-9px -60px 11px 0px;")#
							<span class="detail">#arguments.weeks_togo# more weeks</span>
						</td>
						<td class="bottom_row_td" valign="bottom">
							#application.q.img(path='munich/statistics.png',style="height:18px;margin:-9px -60px 11px 0px;")#
							<span class="detail">#arguments.funded_percentage#% Funded</span>
						</td>
						<td width="20%" style="text-align:right;">								
							<button>Contribute</button>
						</td>
					</tr>
				</table>
			</cfoutput>
		</cfsavecontent>
		
		<cfreturn local.result />
		
	</cffunction>
	
	<!--- --->
	
	<cffunction name="renderFundMiddleRow" access="public" output="false" returntype="string">
		<cfargument name="description" required="false" default="3" />

		<cfset var local = {} />
				
		<cfsavecontent variable="local.result">
			<cfoutput>
				<table width="100%" cellspacing="0" cellpadding="0">
					<tr>
						<td class="fund_middle_icon" valign="bottom">
							#application.q.img(path='y-u-no.jpg',style="height:95px;border:3px solid white;margin-bottom:5px;")#
						</td>
						<td valign="top">
							<div class="normal">#arguments.description#</div>
						</td>
						<td style="width:25%;">
							<span class="detail"></span>
						</td>
					</tr>
				</table>
			</cfoutput>
		</cfsavecontent>
		
		<cfreturn local.result />
		
	</cffunction>
	
	<!--- --->
	
	<cffunction name="renderFunds" access="public" output="false" returntype="string">
		<cfargument name="fundID" required="false" default="" />
		<cfargument name="city" required="false" default="" />
		<cfargument name="stateID" required="false" default="" />
		<cfargument name="email" required="false" default="" />
		<cfargument name="owner_name" required="false" default="" />
		<cfargument name="title" required="false" default="" />
		<cfargument name="description" required="false" default="" />
		<cfargument name="created_date" required="false" default="" />
		<cfargument name="type" required="false" default="" />
				
		<cfset var local = {} />
		
		<cfset local.funds = application.s.fundService.getFunds(argumentCollection=arguments) />
		
		<cfsavecontent variable="local.result">
			<cfoutput>
				<cfloop query="local.funds">
					#renderFund(
						id=local.funds.id,
						title=local.funds.title,
						who=local.funds.who,
						amount=local.funds.amount,
						description=local.funds.description,
						city=local.funds.city,
						state=local.funds.state,
						created=local.funds.created
					)#
				</cfloop>
				<cfif local.funds.recordcount eq 0>
					No Matches
				</cfif>
			</cfoutput>
		</cfsavecontent>
		
		<cfreturn local.result />
		
	</cffunction>
	
	<!--- --->

</cfcomponent>